<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/xhtml;charset=UTF-8"/>
<meta http-equiv="X-UA-Compatible" content="IE=9"/>
<title>TurtleDB: src/ca/uqac/dim/turtledb/util/FileReadWrite.java Source File</title>

<link href="tabs.css" rel="stylesheet" type="text/css"/>
<link href="doxygen.css" rel="stylesheet" type="text/css" />
<link href="navtree.css" rel="stylesheet" type="text/css"/>
<script type="text/javascript" src="jquery.js"></script>
<script type="text/javascript" src="resize.js"></script>
<script type="text/javascript" src="navtree.js"></script>
<script type="text/javascript">
  $(document).ready(initResizable);
</script>


</head>
<body>
<div id="top"><!-- do not remove this div! -->


<div id="titlearea">
<table cellspacing="0" cellpadding="0">
 <tbody>
 <tr style="height: 56px;">
  
  
  <td style="padding-left: 0.5em;">
   <div id="projectname">TurtleDB
   
   </div>
   <div id="projectbrief">A mini distributed database system</div>
  </td>
  
  
  
 </tr>
 </tbody>
</table>
</div>

<!-- Generated by Doxygen 1.7.6.1 -->
  <div id="navrow1" class="tabs">
    <ul class="tablist">
      <li><a href="index.html"><span>Main&#160;Page</span></a></li>
      <li><a href="namespaces.html"><span>Packages</span></a></li>
      <li><a href="annotated.html"><span>Classes</span></a></li>
      <li class="current"><a href="files.html"><span>Files</span></a></li>
    </ul>
  </div>
  <div id="navrow2" class="tabs2">
    <ul class="tablist">
      <li><a href="files.html"><span>File&#160;List</span></a></li>
    </ul>
  </div>
</div>
<div id="side-nav" class="ui-resizable side-nav-resizable">
  <div id="nav-tree">
    <div id="nav-tree-contents">
    </div>
  </div>
  <div id="splitbar" style="-moz-user-select:none;" 
       class="ui-resizable-handle">
  </div>
</div>
<script type="text/javascript">
  initNavTree('_file_read_write_8java.html','');
</script>
<div id="doc-content">
<div class="header">
  <div class="headertitle">
<div class="title">src/ca/uqac/dim/turtledb/util/FileReadWrite.java</div>  </div>
</div><!--header-->
<div class="contents">
<a href="_file_read_write_8java.html">Go to the documentation of this file.</a><div class="fragment"><pre class="fragment"><a name="l00001"></a><a class="code" href="namespaceca_1_1uqac_1_1dim_1_1turtledb_1_1util.html">00001</a> <span class="keyword">package </span>ca.uqac.dim.turtledb.util;
<a name="l00002"></a>00002 
<a name="l00003"></a>00003 <span class="keyword">import</span> java.io.FileInputStream;
<a name="l00004"></a>00004 <span class="keyword">import</span> java.io.IOException;
<a name="l00005"></a>00005 <span class="keyword">import</span> java.util.Scanner;
<a name="l00006"></a>00006 
<a name="l00012"></a><a class="code" href="classca_1_1uqac_1_1dim_1_1turtledb_1_1util_1_1_file_read_write.html">00012</a> <span class="keyword">public</span> <span class="keyword">class </span><a class="code" href="classca_1_1uqac_1_1dim_1_1turtledb_1_1util_1_1_file_read_write.html">FileReadWrite</a>
<a name="l00013"></a>00013 {
<a name="l00017"></a><a class="code" href="classca_1_1uqac_1_1dim_1_1turtledb_1_1util_1_1_file_read_write.html#a6fc42b1b38ad9b6daecfa019cb2621a1">00017</a>         <span class="keyword">public</span> <span class="keyword">static</span> String <a class="code" href="classca_1_1uqac_1_1dim_1_1turtledb_1_1util_1_1_file_read_write.html#a6fc42b1b38ad9b6daecfa019cb2621a1">DEFAULT_ENCODING</a> = <span class="stringliteral">&quot;utf-8&quot;</span>;
<a name="l00018"></a>00018         
<a name="l00026"></a><a class="code" href="classca_1_1uqac_1_1dim_1_1turtledb_1_1util_1_1_file_read_write.html#a2ad368cf5523ca33dbbf9e4940b5b1b4">00026</a>         <span class="keyword">public</span> <span class="keyword">static</span> String <a class="code" href="classca_1_1uqac_1_1dim_1_1turtledb_1_1util_1_1_file_read_write.html#a2ad368cf5523ca33dbbf9e4940b5b1b4">getFileContents</a>(String filename, String encoding) <span class="keywordflow">throws</span> IOException
<a name="l00027"></a>00027         {
<a name="l00028"></a>00028                 StringBuilder text = <span class="keyword">new</span> StringBuilder();
<a name="l00029"></a>00029                 String NL = System.getProperty(<span class="stringliteral">&quot;line.separator&quot;</span>);
<a name="l00030"></a>00030                 Scanner scanner = <span class="keyword">new</span> Scanner(<span class="keyword">new</span> FileInputStream(filename), encoding);
<a name="l00031"></a>00031                 <span class="keywordflow">try</span> {
<a name="l00032"></a>00032                         <span class="keywordflow">while</span> (scanner.hasNextLine()){
<a name="l00033"></a>00033                                 text.append(scanner.nextLine() + NL);
<a name="l00034"></a>00034                         }
<a name="l00035"></a>00035                 }
<a name="l00036"></a>00036                 <span class="keywordflow">finally</span>{
<a name="l00037"></a>00037                         scanner.close();
<a name="l00038"></a>00038                 }
<a name="l00039"></a>00039                 <span class="keywordflow">return</span> text.toString();
<a name="l00040"></a>00040         }
<a name="l00041"></a>00041         
<a name="l00042"></a><a class="code" href="classca_1_1uqac_1_1dim_1_1turtledb_1_1util_1_1_file_read_write.html#af7e927efaf629e5f36cb8a7e541801e9">00042</a>         <span class="keyword">public</span> <span class="keyword">static</span> String <a class="code" href="classca_1_1uqac_1_1dim_1_1turtledb_1_1util_1_1_file_read_write.html#a2ad368cf5523ca33dbbf9e4940b5b1b4">getFileContents</a>(String filename) <span class="keywordflow">throws</span> IOException
<a name="l00043"></a>00043         {
<a name="l00044"></a>00044                 <span class="keywordflow">return</span> <a class="code" href="classca_1_1uqac_1_1dim_1_1turtledb_1_1util_1_1_file_read_write.html#a2ad368cf5523ca33dbbf9e4940b5b1b4">getFileContents</a>(filename, <a class="code" href="classca_1_1uqac_1_1dim_1_1turtledb_1_1util_1_1_file_read_write.html#a6fc42b1b38ad9b6daecfa019cb2621a1">DEFAULT_ENCODING</a>);
<a name="l00045"></a>00045         }
<a name="l00046"></a>00046 }
</pre></div></div><!-- contents -->
</div>
  <div id="nav-path" class="navpath">
    <ul>
      <li class="navelem"><a class="el" href="_file_read_write_8java.html">FileReadWrite.java</a>      </li>

    <li class="footer">Generated on Tue Nov 20 2012 13:26:48 for TurtleDB by
    <a href="http://www.doxygen.org/index.html">
    <img class="footer" src="doxygen.png" alt="doxygen"/></a> 1.7.6.1 </li>
   </ul>
 </div>


</body>
</html>
